package com.spring.boot.entity;


/**
 * 分页类
 */
@SuppressWarnings("unused")
public class Page {
	private int showCount; //每页显示记录数
	private int totalPage;		//总页数
	private int totalResult;	//总记录数
	private int currentPage;	//当前页
	private int currentResult;	//当前记录起始索引
	private int startSize; // 起始条数
	private int endSize; //结尾条码
	
	public int getStartSize() {
		return startSize = currentPage * showCount;
	}
	
	public int getEndSize() {
		return endSize = (currentPage+1) * showCount;
	}
	
	public int getShowCount() {
		return showCount;
	}
	public void setShowCount(int showCount) {
		this.showCount = showCount;
	}
	public int getTotalPage() {
		if(totalResult%showCount==0) {
			totalPage = totalResult/showCount;
		}else{
			totalPage = totalResult/showCount+1;
		}
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getTotalResult() {
		return totalResult;
	}
	public void setTotalResult(int totalResult) {
		this.totalResult = totalResult;
	}
	public int getCurrentPage() {
		//判断页码 小于等于零 从零开始
		if(currentPage<=0) {
			currentPage = 0;
		}
		//判断 当前页码 大于总页数
		if(currentPage>getTotalPage()) {
			currentPage = getTotalPage();
		}
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getCurrentResult() {
		currentResult = (getCurrentPage()-1)*getShowCount();
		if(currentResult<0) {
			currentResult = 0;
		}
		return currentResult;
	}
	public void setCurrentResult(int currentResult) {
		this.currentResult = currentResult;
	}
}
